package cn.edu.xmu.orderpayment.order.model.bo;

import cn.edu.xmu.orderpayment.order.model.enums.OrderState;
import cn.edu.xmu.orderpayment.order.model.po.OrderPo;
import cn.edu.xmu.privilegegateway.annotation.util.Common;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Yujie Lin
 * @date 2021/12/4 13:01
 */
@Data
public class Order {
    private Long id;
    private Long customerId;
    private Long shopId;
    private String orderSn;
    private Long pid;
    private String consignee;
    private Long regionId;
    private String address;
    private String mobile;
    private String message;
    private Long advancesaleId;
    private Long grouponId;
    private Long expressFee;
    private Long discountPrice;
    private Long originPrice;
    private Long point;
    private LocalDateTime confirmTime;
    private String shipmentSn;
    private Integer state;
    private Byte beDeleted;
    private Long creatorId;
    private String creatorName;
    private Long modifierId;
    private String modifierName;
    private LocalDateTime gmtCreate;
    private LocalDateTime gmtModified;

    private List<OrderItem> orderItems;

    public OrderState getState() {
        return OrderState.getOrderStateByCode(state);
    }

    public void setState(OrderState state) {
        this.state=state.getCode();
    }

    public void init(){
        this.pid=0L;
        this.orderSn= Common.genSeqNum(1);
        this.expressFee=0L;
        this.discountPrice=0L;
        this.originPrice=0L;
        this.point=0L;
        this.setState(OrderState.NEW_ORDER);
        this.beDeleted=((byte)0);
    }

}
